package thesis.prototype.objects;

import android.os.Parcel;
import android.os.Parcelable;

public class Contact implements Parcelable {
	
	private String name;
	private String number;

	public Contact(String name, String number) {
		this.name = name;
		this.number = number;
	}

	public String getName() {
		return name;
	}

	public String getNumber() {
		return number;
	}

	@Override
	public String toString()
	{
		return getName() + "\n" + getNumber();
	}

	// PARCELABLE METHODS BEGIN HERE
	
	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeString(name);
		dest.writeString(number);
		
	}
	
	public Contact(Parcel in) {
		readFromParcel(in);
	}
	
	private void readFromParcel(Parcel in) {
		 
		// We just need to read back each
		// field in the order that it was
		// written to the parcel
		name = in.readString();
		number = in.readString();
	}
	
    public static final Parcelable.Creator<Contact> CREATOR =
    	new Parcelable.Creator<Contact>() {
            public Contact createFromParcel(Parcel in) {
                return new Contact(in);
            }
 
            public Contact[] newArray(int size) {
                return new Contact[size];
            }
        };
}
